package practice1_100;

import java.util.HashMap;
import java.util.List;

public class Practice690 {
    public int getImportance(List<Employee> employees, int id) {
        int importances=0;
        HashMap<Integer,Employee> map=new HashMap<>();
        for (Employee e:employees) {
            map.put(e.id,e);
        }
        return getIm(id,map);

    }

    public int getIm(int id,HashMap<Integer,Employee> map){
        Employee e= map.get(id);
        int ans=e.importance;
        for (int oid:e.subordinates) {
            Employee employee=map.get(oid);
            ans+=employee.importance;
            for (int sub:employee.subordinates) ans+=getIm(sub,map);
        }
        return ans;
    }
}
class Employee {
    public int id;
    public int importance;
    public List<Integer> subordinates;
};
